package com.rocketmq.controller;

import com.rocketmq.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "product")
public class ProductController {


    @Autowired
    private IProductService productService;


    /**
     * 设置商品信息
     *
     * @param name
     * @param store
     * @return
     */
    @GetMapping("setStore")
    public String setStore(String name, int store) {
        return productService.setStore(name, store);
    }

    /**
     * 获取商品信息
     *
     * @return
     */
    @GetMapping("getProduct")
    public String getProduct() {
        return productService.getProduct();
    }


    /**
     * 抢购
     *
     * @param productId
     * @param userId
     * @return
     */
    @GetMapping("rushToPurchase")
    public String rushToPurchase(int productId, int userId) {
        return productService.rushToPurchase(productId, userId);
    }

}
